
//--------------------------------------------------
//
// auto generated file, do not change it here but check corresponding *.met/*.def file
//
//--------------------------------------------------
#include <sstream>
#include <vector>
#include <QtGlobal> // qrand
#include "tinyXML/tinyxml.h"
#include "TinyXmlWrapper.h"
#include "Configuration.h"

namespace yasa
{
namespace configuration
{
 
ISTCommonData::ISTCommonData()
{
     id = qrand(); 
    
}

 
ISTItem::ISTItem() : ISTCommonData()
{
    
}

 
std::string ISTItem::toXml(TiXmlElement *parentNode)
{
    
    TiXmlElement *parent;
    if (parentNode == nullptr)
    {
        parent = new TiXmlElement("ISTItem");
    }
    else
    {
        parent = parentNode;
    }
    
    
    { // id
        std::stringstream oss;
        oss << id;
        parent->SetAttribute("id", oss.str().c_str());
    }
    
    
    { // name
        std::stringstream oss;
        oss << name;
        parent->SetAttribute("name", oss.str().c_str());
    }
    
    
    { // description
        std::stringstream oss;
        oss << description;
        parent->SetAttribute("description", oss.str().c_str());
    }
    
    
    { // imagePath
        std::stringstream oss;
        oss << imagePath;
        parent->SetAttribute("imagePath", oss.str().c_str());
    }
    
    
    { // soundPath
        std::stringstream oss;
        oss << soundPath;
        parent->SetAttribute("soundPath", oss.str().c_str());
    }
    
     
    
    if (parentNode == nullptr)
    {
        TiXmlDocument doc;
        doc.LinkEndChild(parent);
    
        TiXmlPrinter printer;
        printer.SetIndent("    ");
        doc.Accept(&printer);
        return printer.CStr();
    }
    else
    {
        return "";
    }
    
}

 
void ISTItem::fromXml(const std::string &xml, TiXmlElement *parentNode)
{
    
    TiXmlElement *root;
    TiXmlDocument doc;
    
    if (parentNode == nullptr)
    {
        doc.Parse(xml.c_str());
        root = doc.RootElement();
    }
    else
    {
        root = parentNode;
    }
    
    
    
    // id
    root->Attribute("id", &id);
    
    
      
    
    // name
    {
        const char *s = root->Attribute("name");
        if (s != nullptr)
        {
            name = s;
        }
    }
    
    
    // description
    {
        const char *s = root->Attribute("description");
        if (s != nullptr)
        {
            description = s;
        }
    }
    
    
    // imagePath
    {
        const char *s = root->Attribute("imagePath");
        if (s != nullptr)
        {
            imagePath = s;
        }
    }
    
    
    // soundPath
    {
        const char *s = root->Attribute("soundPath");
        if (s != nullptr)
        {
            soundPath = s;
        }
    }
    
     
    
    
     
     
    
    
}

 
ISTCategory::ISTCategory() : ISTCommonData()
{
    
}

 
std::string ISTCategory::toXml(TiXmlElement *parentNode)
{
    
    TiXmlElement *parent;
    if (parentNode == nullptr)
    {
        parent = new TiXmlElement("ISTCategory");
    }
    else
    {
        parent = parentNode;
    }
    
    
    { // id
        std::stringstream oss;
        oss << id;
        parent->SetAttribute("id", oss.str().c_str());
    }
    
    
    { // name
        std::stringstream oss;
        oss << name;
        parent->SetAttribute("name", oss.str().c_str());
    }
    
    
    { // description
        std::stringstream oss;
        oss << description;
        parent->SetAttribute("description", oss.str().c_str());
    }
    
    
    { // imagePath
        std::stringstream oss;
        oss << imagePath;
        parent->SetAttribute("imagePath", oss.str().c_str());
    }
    
    
    { // soundPath
        std::stringstream oss;
        oss << soundPath;
        parent->SetAttribute("soundPath", oss.str().c_str());
    }
    
     
    // write array categories
    TiXmlElement * categories_element = new TiXmlElement("categories");
    parent->LinkEndChild(categories_element);
    categories_element->SetAttribute("size", categories.size());
    
    TiXmlElement * parent_categories = parent;
    parent = categories_element;
    
    for (size_t i = 0; i < categories.size(); i++)
    {
        struct yasa::configuration::ISTCategory &ISTCategory = categories[i];
    
         
        { // ISTCategory
            TiXmlElement * element = new TiXmlElement("ISTCategory");
            std::string xml = ISTCategory.toXml(element);
            parent->LinkEndChild(element);
        }
        
    }
    
    parent = parent_categories;
    
     
    // write array items
    TiXmlElement * items_element = new TiXmlElement("items");
    parent->LinkEndChild(items_element);
    
    for (size_t i = 0; i < items.size(); i++)
    {
        int32_t &value_1 = items[i];
    
        TiXmlElement * element_2 = new TiXmlElement("int32");
        
        std::stringstream oss;
        oss << value_1;
        element_2->SetAttribute("value", oss.str().c_str());
    
        items_element->LinkEndChild(element_2);
    }
    
     
    
    if (parentNode == nullptr)
    {
        TiXmlDocument doc;
        doc.LinkEndChild(parent);
    
        TiXmlPrinter printer;
        printer.SetIndent("    ");
        doc.Accept(&printer);
        return printer.CStr();
    }
    else
    {
        return "";
    }
    
}

 
void ISTCategory::fromXml(const std::string &xml, TiXmlElement *parentNode)
{
    
    TiXmlElement *root;
    TiXmlDocument doc;
    
    if (parentNode == nullptr)
    {
        doc.Parse(xml.c_str());
        root = doc.RootElement();
    }
    else
    {
        root = parentNode;
    }
    
    
    
    // id
    root->Attribute("id", &id);
    
    
      
    
    // name
    {
        const char *s = root->Attribute("name");
        if (s != nullptr)
        {
            name = s;
        }
    }
    
    
    // description
    {
        const char *s = root->Attribute("description");
        if (s != nullptr)
        {
            description = s;
        }
    }
    
    
    // imagePath
    {
        const char *s = root->Attribute("imagePath");
        if (s != nullptr)
        {
            imagePath = s;
        }
    }
    
    
    // soundPath
    {
        const char *s = root->Attribute("soundPath");
        if (s != nullptr)
        {
            soundPath = s;
        }
    }
    
     
    
    
     
     
    // read array categories
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "categories") == 0)
        {
            TiXmlElement *element = child->ToElement();
    
            TiXmlElement *originalRoot = root;
    
            for (TiXmlNode *arrayChild = element->FirstChild(); arrayChild != 0; arrayChild = arrayChild->NextSibling()) 
            {
                root = arrayChild->ToElement();
                
                struct yasa::configuration::ISTCategory value;
    
                if (strcmp("ISTCategory", root->Value()) == 0)
                {
                    
                    // value
                    value.fromXml("", root);
                    
    
                    categories.push_back(value);
                }
            }
    
            root = originalRoot;
    
            break;
        }
    }
    
     
    // read array items
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "items") == 0)
        {
            TiXmlElement *element = child->ToElement();
    
            TiXmlElement *originalRoot = root;
    
            for (TiXmlNode *arrayChild = element->FirstChild(); arrayChild != 0; arrayChild = arrayChild->NextSibling()) 
            {
                root = arrayChild->ToElement();
                
                int32_t value;
    
                if (strcmp("int32", root->Value()) == 0)
                {
                    
                    // value
                    root->Attribute("value", &value);
                    
    
                    items.push_back(value);
                }
            }
    
            root = originalRoot;
    
            break;
        }
    }
    
     
    
    
}

 
Rect::Rect()
{
     x = 10; 
     y = 10; 
     width = 500; 
     height = 500; 
    
}

 
std::string Rect::toXml(TiXmlElement *parentNode)
{
    
    TiXmlElement *parent;
    if (parentNode == nullptr)
    {
        parent = new TiXmlElement("Rect");
    }
    else
    {
        parent = parentNode;
    }
    
    
    { // x
        std::stringstream oss;
        oss << x;
        parent->SetAttribute("x", oss.str().c_str());
    }
    
    
    { // y
        std::stringstream oss;
        oss << y;
        parent->SetAttribute("y", oss.str().c_str());
    }
    
    
    { // width
        std::stringstream oss;
        oss << width;
        parent->SetAttribute("width", oss.str().c_str());
    }
    
    
    { // height
        std::stringstream oss;
        oss << height;
        parent->SetAttribute("height", oss.str().c_str());
    }
    
     
    
    if (parentNode == nullptr)
    {
        TiXmlDocument doc;
        doc.LinkEndChild(parent);
    
        TiXmlPrinter printer;
        printer.SetIndent("    ");
        doc.Accept(&printer);
        return printer.CStr();
    }
    else
    {
        return "";
    }
    
}

 
void Rect::fromXml(const std::string &xml, TiXmlElement *parentNode)
{
    
    TiXmlElement *root;
    TiXmlDocument doc;
    
    if (parentNode == nullptr)
    {
        doc.Parse(xml.c_str());
        root = doc.RootElement();
    }
    else
    {
        root = parentNode;
    }
    
    
    
    // x
    root->Attribute("x", &x);
    
    
    // y
    root->Attribute("y", &y);
    
    
    // width
    root->Attribute("width", &width);
    
    
    // height
    root->Attribute("height", &height);
    
    
      
     
    
    
     
     
    
    
}

 
Configuration::Configuration()
{
    
}

 
std::string Configuration::toXml(TiXmlElement *parentNode)
{
    
    TiXmlElement *parent;
    if (parentNode == nullptr)
    {
        parent = new TiXmlElement("Configuration");
    }
    else
    {
        parent = parentNode;
    }
    
     
    { // theRoot
        TiXmlElement * element = new TiXmlElement("theRoot");
        std::string xml = theRoot.toXml(element);
        parent->LinkEndChild(element);
    }
    
     
    // write array items
    TiXmlElement * items_element = new TiXmlElement("items");
    parent->LinkEndChild(items_element);
    items_element->SetAttribute("size", items.size());
    
    TiXmlElement * parent_items = parent;
    parent = items_element;
    
    for (size_t i = 0; i < items.size(); i++)
    {
        struct yasa::configuration::ISTItem &ISTItem = items[i];
    
         
        { // ISTItem
            TiXmlElement * element = new TiXmlElement("ISTItem");
            std::string xml = ISTItem.toXml(element);
            parent->LinkEndChild(element);
        }
        
    }
    
    parent = parent_items;
    
     
    { // mainWindowRect
        TiXmlElement * element = new TiXmlElement("mainWindowRect");
        std::string xml = mainWindowRect.toXml(element);
        parent->LinkEndChild(element);
    }
    
     
    { // propertiesWindowRect
        TiXmlElement * element = new TiXmlElement("propertiesWindowRect");
        std::string xml = propertiesWindowRect.toXml(element);
        parent->LinkEndChild(element);
    }
    
     
    
    if (parentNode == nullptr)
    {
        TiXmlDocument doc;
        doc.LinkEndChild(parent);
    
        TiXmlPrinter printer;
        printer.SetIndent("    ");
        doc.Accept(&printer);
        return printer.CStr();
    }
    else
    {
        return "";
    }
    
}

 
void Configuration::fromXml(const std::string &xml, TiXmlElement *parentNode)
{
    
    TiXmlElement *root;
    TiXmlDocument doc;
    
    if (parentNode == nullptr)
    {
        doc.Parse(xml.c_str());
        root = doc.RootElement();
    }
    else
    {
        root = parentNode;
    }
    
    
    
      
     
    
    
     
    // theRoot
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "theRoot") == 0)
        {
            TiXmlElement *element = child->ToElement();
            theRoot.fromXml("", element);
            break;
        }
    }
    
    
     
    // mainWindowRect
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "mainWindowRect") == 0)
        {
            TiXmlElement *element = child->ToElement();
            mainWindowRect.fromXml("", element);
            break;
        }
    }
    
    
     
    // propertiesWindowRect
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "propertiesWindowRect") == 0)
        {
            TiXmlElement *element = child->ToElement();
            propertiesWindowRect.fromXml("", element);
            break;
        }
    }
    
    
     
     
    // read array items
    for (TiXmlNode *child = root->FirstChild(); child != 0; child = child->NextSibling()) 
    {
        if (strcmp(child->Value(), "items") == 0)
        {
            TiXmlElement *element = child->ToElement();
    
            TiXmlElement *originalRoot = root;
    
            for (TiXmlNode *arrayChild = element->FirstChild(); arrayChild != 0; arrayChild = arrayChild->NextSibling()) 
            {
                root = arrayChild->ToElement();
                
                struct yasa::configuration::ISTItem value;
    
                if (strcmp("ISTItem", root->Value()) == 0)
                {
                    
                    // value
                    value.fromXml("", root);
                    
    
                    items.push_back(value);
                }
            }
    
            root = originalRoot;
    
            break;
        }
    }
    
     
    
    
}


}

}
